/*
 * jQuery File Upload Plugin JS Example 8.9.1
 * https://github.com/blueimp/jQuery-File-Upload
 *
 * Copyright 2010, Sebastian Tschan
 * https://blueimp.net
 *
 * Licensed under the MIT license:
 * http://www.opensource.org/licenses/MIT
 */

/* global $, window */

$(function () {
    'use strict';

    // Initialize the jQuery File Upload widget:
    $('#fileupload').fileupload({
    	acceptFileTypes:/(\.|\/)(gif|jpe?g|png|doc|docx|xls|xlsx|ppt|pptx|pdf|dwg|dwt|txt|zip|rar)$/i,
        // Uncomment the following to send cross-domain cookies:
    	maxFileSize: 100 * 1024 * 1024,
    	minFileSize: 5,
    	maxNumberOfFiles: 50,
    	messages: {
    	    maxFileSize: '附件最大不能超过10兆',
    	    acceptFileTypes: '只能上传档案文档，图片类文件'
    	},
        url: appConfig.contPath + '/attachment/filesUpload.do'
    });
//       var url = location.href + "&f=json";
    var tableId = getQueryString("tableId");
    var partId = getQueryString("partId");
    var url = appConfig.contPath + '/attachment/upFiles.do?tableId='+tableId+'&partId='+partId;
       console.log(url)
        // Load existing files:
        $('#fileupload').addClass('fileupload-processing');
         
        $.ajax({
            // Uncomment the following to send cross-domain cookies:
            //xhrFields: {withCredentials: true},
            url:url,
            dataType: 'json',
            context: $('#fileupload')[0]
        }).always(function () {
            $(this).removeClass('fileupload-processing');
        }).done(function (result) {
            $(this).fileupload('option', 'done')
                .call(this, $.Event('done'), {result: result});
        });


});
